<?php


abstract class BaseDemandeEvaluation extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $demande_evaluation_id;


	
	protected $date;


	
	protected $evaluateur;


	
	protected $demande_id;


	
	protected $is_donnees_dispo;


	
	protected $is_ok_objectifs_oru;


	
	protected $is_ok_anonymat;


	
	protected $interet;


	
	protected $commentaire;

	
	protected $aDemande;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getDemandeEvaluationId()
	{

		return $this->demande_evaluation_id;
	}

	
	public function getDate($format = 'Y-m-d H:i:s')
	{

		if ($this->date === null || $this->date === '') {
			return null;
		} elseif (!is_int($this->date)) {
						$ts = strtotime($this->date);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [date] as date/time value: " . var_export($this->date, true));
			}
		} else {
			$ts = $this->date;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function getEvaluateur()
	{

		return $this->evaluateur;
	}

	
	public function getDemandeId()
	{

		return $this->demande_id;
	}

	
	public function getIsDonneesDispo()
	{

		return $this->is_donnees_dispo;
	}

	
	public function getIsOkObjectifsOru()
	{

		return $this->is_ok_objectifs_oru;
	}

	
	public function getIsOkAnonymat()
	{

		return $this->is_ok_anonymat;
	}

	
	public function getInteret()
	{

		return $this->interet;
	}

	
	public function getCommentaire()
	{

		return $this->commentaire;
	}

	
	public function setDemandeEvaluationId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->demande_evaluation_id !== $v) {
			$this->demande_evaluation_id = $v;
			$this->modifiedColumns[] = DemandeEvaluationPeer::DEMANDE_EVALUATION_ID;
		}

	} 
	
	public function setDate($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [date] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->date !== $ts) {
			$this->date = $ts;
			$this->modifiedColumns[] = DemandeEvaluationPeer::DATE;
		}

	} 
	
	public function setEvaluateur($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->evaluateur !== $v) {
			$this->evaluateur = $v;
			$this->modifiedColumns[] = DemandeEvaluationPeer::EVALUATEUR;
		}

	} 
	
	public function setDemandeId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->demande_id !== $v) {
			$this->demande_id = $v;
			$this->modifiedColumns[] = DemandeEvaluationPeer::DEMANDE_ID;
		}

		if ($this->aDemande !== null && $this->aDemande->getDemandeId() !== $v) {
			$this->aDemande = null;
		}

	} 
	
	public function setIsDonneesDispo($v)
	{

		if ($this->is_donnees_dispo !== $v) {
			$this->is_donnees_dispo = $v;
			$this->modifiedColumns[] = DemandeEvaluationPeer::IS_DONNEES_DISPO;
		}

	} 
	
	public function setIsOkObjectifsOru($v)
	{

		if ($this->is_ok_objectifs_oru !== $v) {
			$this->is_ok_objectifs_oru = $v;
			$this->modifiedColumns[] = DemandeEvaluationPeer::IS_OK_OBJECTIFS_ORU;
		}

	} 
	
	public function setIsOkAnonymat($v)
	{

		if ($this->is_ok_anonymat !== $v) {
			$this->is_ok_anonymat = $v;
			$this->modifiedColumns[] = DemandeEvaluationPeer::IS_OK_ANONYMAT;
		}

	} 
	
	public function setInteret($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->interet !== $v) {
			$this->interet = $v;
			$this->modifiedColumns[] = DemandeEvaluationPeer::INTERET;
		}

	} 
	
	public function setCommentaire($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->commentaire !== $v) {
			$this->commentaire = $v;
			$this->modifiedColumns[] = DemandeEvaluationPeer::COMMENTAIRE;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->demande_evaluation_id = $rs->getInt($startcol + 0);

			$this->date = $rs->getTimestamp($startcol + 1, null);

			$this->evaluateur = $rs->getInt($startcol + 2);

			$this->demande_id = $rs->getInt($startcol + 3);

			$this->is_donnees_dispo = $rs->getBoolean($startcol + 4);

			$this->is_ok_objectifs_oru = $rs->getBoolean($startcol + 5);

			$this->is_ok_anonymat = $rs->getBoolean($startcol + 6);

			$this->interet = $rs->getInt($startcol + 7);

			$this->commentaire = $rs->getString($startcol + 8);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 9; 
		} catch (Exception $e) {
			throw new PropelException("Error populating DemandeEvaluation object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(DemandeEvaluationPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			DemandeEvaluationPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(DemandeEvaluationPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


												
			if ($this->aDemande !== null) {
				if ($this->aDemande->isModified()) {
					$affectedRows += $this->aDemande->save($con);
				}
				$this->setDemande($this->aDemande);
			}


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = DemandeEvaluationPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setDemandeEvaluationId($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += DemandeEvaluationPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


												
			if ($this->aDemande !== null) {
				if (!$this->aDemande->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aDemande->getValidationFailures());
				}
			}


			if (($retval = DemandeEvaluationPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = DemandeEvaluationPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getDemandeEvaluationId();
				break;
			case 1:
				return $this->getDate();
				break;
			case 2:
				return $this->getEvaluateur();
				break;
			case 3:
				return $this->getDemandeId();
				break;
			case 4:
				return $this->getIsDonneesDispo();
				break;
			case 5:
				return $this->getIsOkObjectifsOru();
				break;
			case 6:
				return $this->getIsOkAnonymat();
				break;
			case 7:
				return $this->getInteret();
				break;
			case 8:
				return $this->getCommentaire();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = DemandeEvaluationPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getDemandeEvaluationId(),
			$keys[1] => $this->getDate(),
			$keys[2] => $this->getEvaluateur(),
			$keys[3] => $this->getDemandeId(),
			$keys[4] => $this->getIsDonneesDispo(),
			$keys[5] => $this->getIsOkObjectifsOru(),
			$keys[6] => $this->getIsOkAnonymat(),
			$keys[7] => $this->getInteret(),
			$keys[8] => $this->getCommentaire(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = DemandeEvaluationPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setDemandeEvaluationId($value);
				break;
			case 1:
				$this->setDate($value);
				break;
			case 2:
				$this->setEvaluateur($value);
				break;
			case 3:
				$this->setDemandeId($value);
				break;
			case 4:
				$this->setIsDonneesDispo($value);
				break;
			case 5:
				$this->setIsOkObjectifsOru($value);
				break;
			case 6:
				$this->setIsOkAnonymat($value);
				break;
			case 7:
				$this->setInteret($value);
				break;
			case 8:
				$this->setCommentaire($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = DemandeEvaluationPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setDemandeEvaluationId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setDate($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setEvaluateur($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setDemandeId($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setIsDonneesDispo($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setIsOkObjectifsOru($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setIsOkAnonymat($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setInteret($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setCommentaire($arr[$keys[8]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(DemandeEvaluationPeer::DATABASE_NAME);

		if ($this->isColumnModified(DemandeEvaluationPeer::DEMANDE_EVALUATION_ID)) $criteria->add(DemandeEvaluationPeer::DEMANDE_EVALUATION_ID, $this->demande_evaluation_id);
		if ($this->isColumnModified(DemandeEvaluationPeer::DATE)) $criteria->add(DemandeEvaluationPeer::DATE, $this->date);
		if ($this->isColumnModified(DemandeEvaluationPeer::EVALUATEUR)) $criteria->add(DemandeEvaluationPeer::EVALUATEUR, $this->evaluateur);
		if ($this->isColumnModified(DemandeEvaluationPeer::DEMANDE_ID)) $criteria->add(DemandeEvaluationPeer::DEMANDE_ID, $this->demande_id);
		if ($this->isColumnModified(DemandeEvaluationPeer::IS_DONNEES_DISPO)) $criteria->add(DemandeEvaluationPeer::IS_DONNEES_DISPO, $this->is_donnees_dispo);
		if ($this->isColumnModified(DemandeEvaluationPeer::IS_OK_OBJECTIFS_ORU)) $criteria->add(DemandeEvaluationPeer::IS_OK_OBJECTIFS_ORU, $this->is_ok_objectifs_oru);
		if ($this->isColumnModified(DemandeEvaluationPeer::IS_OK_ANONYMAT)) $criteria->add(DemandeEvaluationPeer::IS_OK_ANONYMAT, $this->is_ok_anonymat);
		if ($this->isColumnModified(DemandeEvaluationPeer::INTERET)) $criteria->add(DemandeEvaluationPeer::INTERET, $this->interet);
		if ($this->isColumnModified(DemandeEvaluationPeer::COMMENTAIRE)) $criteria->add(DemandeEvaluationPeer::COMMENTAIRE, $this->commentaire);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(DemandeEvaluationPeer::DATABASE_NAME);

		$criteria->add(DemandeEvaluationPeer::DEMANDE_EVALUATION_ID, $this->demande_evaluation_id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getDemandeEvaluationId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setDemandeEvaluationId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setDate($this->date);

		$copyObj->setEvaluateur($this->evaluateur);

		$copyObj->setDemandeId($this->demande_id);

		$copyObj->setIsDonneesDispo($this->is_donnees_dispo);

		$copyObj->setIsOkObjectifsOru($this->is_ok_objectifs_oru);

		$copyObj->setIsOkAnonymat($this->is_ok_anonymat);

		$copyObj->setInteret($this->interet);

		$copyObj->setCommentaire($this->commentaire);


		$copyObj->setNew(true);

		$copyObj->setDemandeEvaluationId(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new DemandeEvaluationPeer();
		}
		return self::$peer;
	}

	
	public function setDemande($v)
	{


		if ($v === null) {
			$this->setDemandeId(NULL);
		} else {
			$this->setDemandeId($v->getDemandeId());
		}


		$this->aDemande = $v;
	}


	
	public function getDemande($con = null)
	{
		if ($this->aDemande === null && ($this->demande_id !== null)) {
						$this->aDemande = DemandePeer::retrieveByPK($this->demande_id, $con);

			
		}
		return $this->aDemande;
	}

} 